import React from 'react'
class Index extends React.Component {
  state = {
    count: 1,
    price: 100
  }
  render() {
    return (
      <div ref={this.ul}>
        <img src="https://robohash.org/123?set=set5" alt="" />

        <button onClick={() => this.setState({ count: this.state.count - 1 })}>-</button>
        <span>{this.state.count}</span>
        <button onClick={() => this.setState({ count: this.state.count + 1 })}>+</button>

      <div>
        单价：{this.state.price}
        小记：{ this.state.price * this.state.count }
      </div>
      </div>  
    )
  }
  shouldComponentUpdate(nextProps, nextState) {
    console.log(nextState)
    if(nextState.count > 5) return false
    if(nextState.count < 1) return false

    return true
  }
}

export default Index;